package com.fliangyun.nsa.nsamanage.config;

import com.fliangyun.nsa.nsamanage.utils.FileUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author fuliangyun@139.com
 * @date 2021年04月30日
 * @description
 */
@Configuration
public class ResourcesConfig implements WebMvcConfigurer {

    @Value("${nsa.base.folder}")
    String baseFileFolder;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/file/**").addResourceLocations("file:"+ FileUtil.getPath(baseFileFolder, ""));
    }

}
